/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SStoreConverter.java
 * Created：		2016年7月30日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.user.converter;


import org.springframework.core.convert.converter.Converter;
import com.thor.commons.entity.UCN;
import com.thor.palmmall.rest.user.AChannel;
import com.thor.palmmall.spi.user.SChannel;

/**
 * @author Captain
 *
 */
public class AChannelConverter implements Converter<SChannel, AChannel> {

  public static AChannelConverter getInstance() {
    if (instance == null)
      instance = new AChannelConverter();
    return instance;
  }

  private static AChannelConverter instance;

  private AChannelConverter() {
  }

  @Override
  public AChannel convert(SChannel source) {
    if (source == null)
      return null;

    AChannel target = new AChannel();
    target.setPaymentType(UCN.newInstance(source.getPaymentType()));
    target.setContent(source.getContent());
    target.setType(source.getType());
    
    target.setContents(AChannelContentsConverter.getInstance().convert(source.getContents()));

    return target;
  }

}
